<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue 计算属性示例</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@3"></script>
</head>

<body>
    <div id="app">
        <h1>计算属性示例</h1>
        <input type="number" v-model="num1" placeholder="输入第一个数字">
        <input type="number" v-model="num2" placeholder="输入第二个数字">
        <p>总和: {{ total }}</p> <!-- 使用计算属性 -->
        <p>乘果: {{ result }}</p>
    </div>

    <script>
        const { createApp } = Vue;
        //—————————————————————————————————选项式——————————————————————————
        createApp({
            data() {
                return {
                    num1: 0,
                    num2: 0
                };
            },
            computed: {
                total() {
                    return this.num1 + this.num2; // 计算两个数的和
                },
                result() {
                    return this.num1 * this.num2;
                }
            }
        }).mount('#app');
    </script>
</body>

</html>